package com.bdqn.hello;

import com.bdqn.pojo.News;

import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
 * HelloSpring
 *
 * @author LILIBO
 * @since 2024/7/13
 */
public class HelloSpring {

    // 属性
    private String hello = null;

    // List集合
    private List<String> list;

    // Map集合
    private Map<String, Object> map;

    // Properties配置
    private Properties props;

    // Bean对象注入
    private News news;

    // 在Spring框架下，重载构造函数时一定要把默认无参构造函数写出来
    public HelloSpring() {
    }

    // 重写构造函数
    public HelloSpring(String hello) {
        this.hello = hello;
    }

    /**
     * 打印信息
     */
    public void print() {
        System.out.println("Spring say: " + this.getHello());
        if (list != null) {
            System.out.println("-------- " + list.size());
            for (String str : list) {
                System.out.println(str);
            }
        }
        if (map != null) {
            System.out.println("-------- " + map.size());
            for (String key : map.keySet()) {
                System.out.println(key + " : " + map.get(key));
            }
        }
        if (props != null) {
            System.out.println("hello: " + props.get("hello") + " spring: " + props.get("spring"));
        }
        if (news != null) {
            System.out.println(news);
        }
    }

    public String getHello() {
        return hello;
    }

    public void setHello(String hello) {
        this.hello = hello;
    }

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Properties getProps() {
        return props;
    }

    public void setProps(Properties props) {
        this.props = props;
    }

    public News getNews() {
        return news;
    }

    public void setNews(News news) {
        this.news = news;
    }

}
